<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      body {
        width: 100%;
        height: 100%;
      }
      div {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        border: 1px solid rgb(195, 34, 34);
        height: 1000px;
      }

      ul {
        list-style: none;
        padding: 0;
        margin-top: 50px;
        width: 200px;
      }
      li {
        border: solid 1px #ddd;
        padding: 10px;
      }

      li:nth-of-type(odd) {
        background: rgb(154, 206, 50);
      }
    </style>
  </head>
  <body>
    <div>
      <input type="text" name="hd" />
      <ul></ul>
    </div>
  </body>
</html>
<script>
  let obj = {
    data: new Set(), // set对象
    set keyword(word) {
      this.data.add(word);
    },
    show() {
      let ul = document.querySelector("ul");
      ul.innerHTML = "";
      this.data.forEach(function (value) {
        ul.innerHTML += `<li>${value}</li>`;
      });
    },
  };

  let input = document.querySelector("[name='hd']");
  input.addEventListener("blur", function () {
    obj.keyword = this.value; // 这里设置了keyword是set，所以你可以用 = 如果没有设置set那你就正常调用函数一样传值
    obj.show();
  });
</script>
